package com.homedo.odin.solution.controller.wap;

import com.homedo.core.common.base.controller.BaseController;
import com.homedo.core.common.base.dto.Meta;
import com.homedo.core.common.base.dto.ResultData;
import com.homedo.odin.solution.contract.wap.UserLoginAddReq;
import com.homedo.odin.solution.contract.wap.UserLoginResp;
import com.homedo.odin.solution.service.bizservice.wap.UserLoginBizService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "登录信息", tags = {"UserLogin"}, produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/wap")
public class WapUserLoginController extends BaseController<UserLoginBizService> {


    @ApiOperation(value = "M站_增加用户登录信息", notes = "M站_增加用户登录信息", httpMethod = "POST")
    @PostMapping("/user_login")
    public ResultData addUserLogin(@RequestBody UserLoginAddReq request) {
        baseService.addUserLogin(request);
        return ResultData.newInstance(Meta.CODE_200, "增加用户登陆信息成功!");
    }

    @ApiOperation(value = "M站_获取用户登录信息", notes = "M站_获取用户登录信息", response = UserLoginResp.class, httpMethod = "GET")
    @GetMapping("/user_login/{openid}")
    public ResultData getUserLogin(
            @ApiParam(value = "login唯一标识 id", required = true) @PathVariable("openid") String openId) {
        UserLoginResp response = baseService.getUserLogin(openId);
        return ResultData.newInstance(Meta.CODE_200, response);
    }
}
